﻿Public MustInherit Class BasicAsyncTask
    Inherits BaseTask

    Private _WaitCompleted As System.Threading.ManualResetEvent

    Public Sub New()
        _WaitCompleted = New Threading.ManualResetEvent(False)
    End Sub

    Public Overrides ReadOnly Property IsAsync() As Boolean
        Get
            Return True
        End Get
    End Property

    Protected Overrides Sub SetCompleted()
        MyBase.SetCompleted()

        _WaitCompleted.Set()
    End Sub

    Protected MustOverride Overrides Sub PerformOperation()

    Public Overrides Sub WaitCompleted()
        _WaitCompleted.WaitOne(Threading.Timeout.Infinite, True)

        If Exception IsNot Nothing Then Throw Exception
    End Sub
End Class